package com.company.cloud.uba.modules.app.controller;


import com.company.cloud.common.asserts.ValidatorUtils;
import com.company.cloud.common.auth.annotation.Login;
import com.company.cloud.common.bean.BaseResult;
import com.company.cloud.common.bean.LoginSimpleUserInfo;
import com.company.cloud.common.redis.service.RedisUtils;
import com.company.cloud.common.utils.AuthContextUtils;
import com.company.cloud.uba.modules.app.controller.req.UserBrowseObjLogQuery4PageParam;
import com.company.cloud.uba.modules.app.controller.req.UserShareAddParam;
import com.company.cloud.uba.modules.app.controller.req.UserShareQuery4PageParam;
import com.company.cloud.uba.modules.base.entity.UserShareInfo;
import com.company.cloud.uba.modules.cache.models.UserBrowseObjLogModel;
import com.company.cloud.uba.modules.cache.models.UserShareModel;
import com.company.cloud.uba.modules.cache.utils.UbaConvertUtil;
import com.company.cloud.uba.modules.mgr.service.UserShareMgrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户分享服务
 */
@RestController
@RequestMapping("/app/uba/share")
@Api(tags="UBA_用户分享服务")
public class UserShareAppController {


    @Autowired
    private UserShareMgrService userShareMgrService;
    @Autowired
    private RedisUtils redisUtils;

    @PostMapping("/addShareLog")
    @ApiOperation(value="新增用户分享日志", response= UserShareModel.class)
    public BaseResult addShareLog(@RequestBody UserShareAddParam params) {
        ValidatorUtils.validate(params);
        UserShareInfo entity= userShareMgrService.addUserShare(params,AuthContextUtils.getShareCode(),
                AuthContextUtils.getUserNoValidate(),AuthContextUtils.getAnonyUserToken(),
                AuthContextUtils.getIp());
        UserShareModel data=UbaConvertUtil.getUserShareCode(entity);
        return BaseResult.ok(data);
    }


    @Login
    @PostMapping("/queryMyShareLog")
    @ApiOperation(value="查询用户分享日志", response= UserShareModel.class)
    public BaseResult queryMyShareLog(@RequestBody UserShareQuery4PageParam params) {



        return BaseResult.ok();
    }







}
